home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Pane.cp < prev    next >
Text File  |  1997-06-28  |  1KB  |  88 lines

  1. // Pane.cp
  2.  
  3. #ifndef Pane_h
  4. #include "Pane.h"
  5. #endif
  6. #ifndef View_h
  7. #include "View.h"
  8. #endif
  9.  
  10. Pane::Pane()
  11.   : window( 0 ),
  12.      bounds( Rectangle::zero ),
  13.      view( 0 )
  14.   {
  15.   }
  16.  
  17. Pane::~Pane()
  18.   {
  19.     if ( view != 0 )
  20.         ClearView();
  21.   }
  22.         
  23. const Sizeable& Pane::Size() const
  24.   {
  25.     if ( view == 0 )
  26.         return Sizeable::empty;
  27.     
  28.     return *view;
  29.   }
  30.  
  31. void Pane::SetView( View& newView )
  32.   {
  33.     Assert( view == 0 );
  34.     Assert( newView.owner == 0 );
  35.     
  36.     view = &newView;
  37.     newView.owner = this;
  38.     
  39.     if ( window != 0 )
  40.         newView.GainMapping();
  41.   }
  42.  
  43. void Pane::ClearView()
  44.   {
  45.     Assert( view != 0 );
  46.     Assert( view->owner == this );
  47.     
  48.     View& oldView = *view;
  49.     view = 0;
  50.     oldView.owner = 0;
  51.     
  52.     if ( window != 0 )
  53.         oldView.LoseMapping();
  54.   }
  55.  
  56. void Pane::MapTo( WindowObject& newWindow )
  57.   {
  58.     Assert( window == 0 );
  59.         
  60.     window = &newWindow;
  61.     
  62.     if ( view != 0 )
  63.         view->GainMapping();
  64.   }
  65.  
  66. void Pane::Unmap()
  67.   {
  68.     Assert( window != 0 );
  69.     
  70.     window = 0;
  71.     bounds = Rectangle::zero;
  72.     
  73.     if ( view != 0 )
  74.         view->LoseMapping();
  75.   }
  76.  
  77. void Pane::SetBounds( Rectangle newBounds )
  78.   {
  79.     if ( bounds == newBounds )
  80.         return;
  81.     
  82.     Rectangle oldBounds( bounds );
  83.     bounds = newBounds;
  84.     
  85.     if ( view != 0 )
  86.         view->ChangeBounds( oldBounds );
  87.   }
  88.